/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ecom.beans.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Mariam Soumaré
 */
@Entity
@Table(name = "produits")
@NamedQueries({
    @NamedQuery(name = "Produits.findAll", query = "SELECT p FROM Produits p"),
    @NamedQuery(name = "Produits.findById", query = "SELECT p FROM Produits p WHERE p.id = :id"),
    @NamedQuery(name = "Produits.findByName", query = "SELECT p FROM Produits p WHERE p.name = :name"),
    @NamedQuery(name = "Produits.findByPrice", query = "SELECT p FROM Produits p WHERE p.price = :price"),
    @NamedQuery(name = "Produits.findByDescription", query = "SELECT p FROM Produits p WHERE p.description = :description"),
    @NamedQuery(name = "Produits.findByQuantity", query = "SELECT p FROM Produits p WHERE p.quantity = :quantity"),
    @NamedQuery(name = "Produits.findByUrl", query = "SELECT p FROM Produits p WHERE p.url = :url")})
public class Produits implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID")
    private Long id;
    @Basic(optional = false)
    @Column(name = "NAME")
    private String name;
    @Basic(optional = false)
    @Column(name = "PRICE")
    private double price;
    @Basic(optional = false)
    @Column(name = "DESCRIPTION")
    private String description;
    @Basic(optional = false)
    @Column(name = "QUANTITY")
    private String quantity;
    @Basic(optional = false)
    @Column(name = "URL")
    private String url;
    @JoinColumn(name = "ID_ProductStore", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private Productstore productstore;
    @JoinColumn(name = "ID_CATEGORY", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private Category category;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "produits")
    private List<Achats> achatsList;

    public Produits() {
    }

    public Produits(Long id) {
        this.id = id;
    }

    public Produits(Long id, String name, double price, String description, String quantity, String url) {
        this.id = id;
        this.name = name;
        this.price = price;
        this.description = description;
        this.quantity = quantity;
        this.url = url;
    }

    public Produits(String productName, double productPrice, String description, String quantity, String url, Category category, Productstore productstore) {
        this.name=productName;
        this.price=productPrice;
        this.description=description;
        this.quantity = quantity;
        this.url=url;
        this.category=category;
        this.productstore=productstore;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getQuantity() {
        return quantity;
    }

    public void setQuantity(String quantity) {
        this.quantity = quantity;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public Productstore getProductstore() {
        return productstore;
    }

    public void setProductstore(Productstore productstore) {
        this.productstore = productstore;
    }

    public Category getCategory() {
        return category;
    }

    public void setCategory(Category category) {
        this.category = category;
    }

    public List<Achats> getAchatsList() {
        return achatsList;
    }

    public void setAchatsList(List<Achats> achatsList) {
        this.achatsList = achatsList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Produits)) {
            return false;
        }
        Produits other = (Produits) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ecom.beans.entity.Produits[id=" + id + "]";
    }

}
